feat: add --context flag to set model context window - #2
Merged
Conversation
Adds an `--context`/`-x` flag to `oc-config add` that records each added model's context window as `limit.context` in the opencode config. Parsing is lenient: human suffixes (k/m/g/t, decimal), absolute counts, fractions, commas/underscores/whitespace, and a trailing "tokens" word are all accepted. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
outofcoffee
force-pushed
the
worktree-context-size
branch
from
June 22, 2026 16:46
405b58e to
126b429
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a
--context/-cflag tooc-config addfor setting a model's context window, with forgiving parsing of human-friendly sizes.Summary
--context/-cflag onoc-config addwrites each added model's window aslimit.contextin the opencode config.k/m/g/t), absolute counts (200000), fractions (1.5m), and stray commas, underscores, whitespace, or a trailingtokensword all parse as you'd expect.limitkeys (e.g.output) are preserved when context is merged in.--providersloses its-cshort alias (long form only) so-ccan serve--context.--ctx-size.Implementation details
Suffixes are decimal (
128k= 128,000 tokens), which matches how context windows are usually quoted, rather than binary (1024). Context is applied to every model added in the invocation by merging alimitmap onto each entry, so it composes with the existing deep-merge write path without clobbering sibling limit keys.